GithubHelp home page GithubHelp logo

spring-boot2-oauth2-auth-server-jwt-mysql's Introduction

spring-boot2-oauth2-auth-server-jwt-mysql's People

Contributors

talk2amareswaran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spring-boot2-oauth2-auth-server-jwt-mysql's Issues

can't get userId / userEmail from authentication

How to get authorities by userId / userEmail instead of userName?

SecurityContextHolder.getContext()
					.setAuthentication(new UsernamePasswordAuthenticationToken(authentication.getName(), null,
							userDetailsService.loadUserByUsername(authentication.getName()).getAuthorities()));

couldn't get other user attributes other than name? May i know how to get that. Even when i try to get authentication.details() which returns null. Please guide me on this.

Note: Raised issue, incase to use only email as only unique column for user table. Otherwise working fine. Thanks!
You can close this, if we can't get userId / userEmail from the refreshToken.
@talk2amareswaran

I treid to post some datas within postman app,however it doesn't work,it returned 404

take a look at the respone,the postman return 404,any idea what wrong I have done?
I tired to post datas to http://localhost:8080/oauth/token,it doesn't work

<!doctype html><title>HTTP Status 404 โ€“ Not Found</title><style >type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font->size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font->size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font->size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font->family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font->family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name >>{color:black;} .line {height:1px;background-color:#525D76;border:none;}</style>>

HTTP Status 404 โ€“ Not Found


Type Status Report

>Message /oauth/token

Description The origin server did not find >a current representation for the target resource or is not willing to disclose that one exists.


class="line" />

Apache Tomcat/8.5.37

USING ORACLE dB

Hi amareswaran,

It is very good tutorial nice explained.
i'm using oracle DB, in oracle bit datatype is not there, so use char and i modify the user class.
i'm getting response like this
{
"error": "unauthorized",
"error_description": "User is disabled"
}

please help me out.

@entity
public class User1 extends BaseIdEntity implements UserDetails {
private static final long serialVersionUID = 1L;
private String email;
private String username;
private String password;
private String enabled;

@Column(name = "account_locked")
private String accountNonLocked;

@Column(name = "account_expired")
private String accountNonExpired;

@Column(name = "credentials_expired")
private String credentialsNonExpired;

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "role_user", joinColumns = {
		@JoinColumn(name = "user_id", referencedColumnName = "id") }, inverseJoinColumns = {
				@JoinColumn(name = "role_id", referencedColumnName = "id") })
private List<Role> roles;

@Override
public boolean isEnabled() {
	return Boolean.valueOf(enabled);
	
}

@Override
public boolean isAccountNonExpired() {
	return !Boolean.valueOf(accountNonExpired);
	
}

@Override
public boolean isCredentialsNonExpired() {
	return !Boolean.valueOf(credentialsNonExpired);
	
}

@Override
public boolean isAccountNonLocked() {
	return !Boolean.valueOf(accountNonLocked);
	
}

/*
 * Get roles and permissions and add them as a Set of GrantedAuthority
 */
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
	Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();

	roles.forEach(r -> {
		authorities.add(new SimpleGrantedAuthority(r.getName()));
		r.getPermissions().forEach(p -> {
			authorities.add(new SimpleGrantedAuthority(p.getName()));
		});
	});

	return authorities;
}

@Override
public String getPassword() {
	return password;
}

@Override
public String getUsername() {
	return username;
}

public String getEmail() {
	return email;
}

public void setEmail(String email) {
	this.email = email;
}

public String getEnabled() {
	return enabled;
}

public void setEnabled(String enabled) {
	this.enabled = enabled;
}

public String getAccountNonLocked() {
	return accountNonLocked;
}

public void setAccountNonLocked(String accountNonLocked) {
	this.accountNonLocked = accountNonLocked;
}

public String getAccountNonExpired() {
	return accountNonExpired;
}

public void setAccountNonExpired(String accountNonExpired) {
	this.accountNonExpired = accountNonExpired;
}

public String getCredentialsNonExpired() {
	return credentialsNonExpired;
}

public void setCredentialsNonExpired(String credentialsNonExpired) {
	this.credentialsNonExpired = credentialsNonExpired;
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.